<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NeuZephyr: nz::Model Class Reference</title>
<link rel="icon" href="NZ_logo2.png" type="image/x-icon" />
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="NZ_logo2.png"/></td>
  <td id="projectalign">
   <div id="projectname">NeuZephyr
   </div>
   <div id="projectbrief">Simple DL Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>nz</b></li><li class="navelem"><a class="el" href="classnz_1_1_model.html">Model</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#related">Related Symbols</a> &#124;
<a href="classnz_1_1_model-members.html">List of all members</a>  </div>
  <div class="headertitle"><div class="title">nz::Model Class Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Base class for constructing neural network models with automatic computation graph management.  
 <a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:abd63329d440cd96c832cbea7c7dfd133" id="r_abd63329d440cd96c832cbea7c7dfd133"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#abd63329d440cd96c832cbea7c7dfd133">Model</a> ()</td></tr>
<tr class="memdesc:abd63329d440cd96c832cbea7c7dfd133"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructs <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> instance with empty computation graph.  <br /></td></tr>
<tr class="separator:abd63329d440cd96c832cbea7c7dfd133"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afaae0d794389dad645bc04558e1c3319" id="r_afaae0d794389dad645bc04558e1c3319"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#afaae0d794389dad645bc04558e1c3319">~Model</a> ()</td></tr>
<tr class="memdesc:afaae0d794389dad645bc04558e1c3319"><td class="mdescLeft">&#160;</td><td class="mdescRight">Safely destructs <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> and associated computation nodes.  <br /></td></tr>
<tr class="separator:afaae0d794389dad645bc04558e1c3319"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad061640ff58f4b09bc850019b27005a8" id="r_ad061640ff58f4b09bc850019b27005a8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1data_1_1_tensor.html">Tensor</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ad061640ff58f4b09bc850019b27005a8">forward</a> ()</td></tr>
<tr class="memdesc:ad061640ff58f4b09bc850019b27005a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes full forward propagation through computation graph.  <br /></td></tr>
<tr class="separator:ad061640ff58f4b09bc850019b27005a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aded49f9b1c9be002bc81ee72dd4e08ac" id="r_aded49f9b1c9be002bc81ee72dd4e08ac"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aded49f9b1c9be002bc81ee72dd4e08ac">backward</a> ()</td></tr>
<tr class="memdesc:aded49f9b1c9be002bc81ee72dd4e08ac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs backward propagation and gradient accumulation.  <br /></td></tr>
<tr class="separator:aded49f9b1c9be002bc81ee72dd4e08ac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9060c98c30fb2388a9fd3ae9af67a046" id="r_a9060c98c30fb2388a9fd3ae9af67a046"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a9060c98c30fb2388a9fd3ae9af67a046">update</a> (<a class="el" href="classnz_1_1opt_1_1_optimizer.html">opt::Optimizer</a> *optimizer) const</td></tr>
<tr class="memdesc:a9060c98c30fb2388a9fd3ae9af67a046"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies parameter updates using attached optimization strategy.  <br /></td></tr>
<tr class="separator:a9060c98c30fb2388a9fd3ae9af67a046"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac9eb518cab0e5df54b986ca6f0233964" id="r_ac9eb518cab0e5df54b986ca6f0233964"><td class="memItemLeft" align="right" valign="top">Tensor::value_type&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ac9eb518cab0e5df54b986ca6f0233964">getLoss</a> () const</td></tr>
<tr class="memdesc:ac9eb518cab0e5df54b986ca6f0233964"><td class="mdescLeft">&#160;</td><td class="mdescRight">Retrieves scalar loss value from last forward pass.  <br /></td></tr>
<tr class="separator:ac9eb518cab0e5df54b986ca6f0233964"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pro-methods" name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:aaabce965b32aa9e32a961631dcdd6540" id="r_aaabce965b32aa9e32a961631dcdd6540"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aaabce965b32aa9e32a961631dcdd6540">Add</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *lhs, <a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *rhs)</td></tr>
<tr class="memdesc:aaabce965b32aa9e32a961631dcdd6540"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates addition operation node in computation graph (Low-level API)  <br /></td></tr>
<tr class="separator:aaabce965b32aa9e32a961631dcdd6540"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0ebe5c8d848f16af5d2a06592c3e2217" id="r_a0ebe5c8d848f16af5d2a06592c3e2217"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a0ebe5c8d848f16af5d2a06592c3e2217">Sub</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *lhs, <a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *rhs)</td></tr>
<tr class="memdesc:a0ebe5c8d848f16af5d2a06592c3e2217"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates subtraction operation node in computation graph (Low-level API)  <br /></td></tr>
<tr class="separator:a0ebe5c8d848f16af5d2a06592c3e2217"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adcd0e6d5ec7e297bf50cd8bbe2077767" id="r_adcd0e6d5ec7e297bf50cd8bbe2077767"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#adcd0e6d5ec7e297bf50cd8bbe2077767">Mul</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *lhs, <a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *rhs)</td></tr>
<tr class="memdesc:adcd0e6d5ec7e297bf50cd8bbe2077767"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates matrix multiplication node in computation graph (Low-level API)  <br /></td></tr>
<tr class="separator:adcd0e6d5ec7e297bf50cd8bbe2077767"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af685ed9088799b290d5bd9d5b34cca95" id="r_af685ed9088799b290d5bd9d5b34cca95"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af685ed9088799b290d5bd9d5b34cca95">Bias</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:af685ed9088799b290d5bd9d5b34cca95"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates trainable bias parameter and adds element-wise to input (Mid-level API)  <br /></td></tr>
<tr class="separator:af685ed9088799b290d5bd9d5b34cca95"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a096c42733e9be0769163e96771c8fc6a" id="r_a096c42733e9be0769163e96771c8fc6a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a096c42733e9be0769163e96771c8fc6a">Reshape</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, const <a class="el" href="classnz_1_1data_1_1_dimension.html">Tensor::shape_type</a> &amp;shape)</td></tr>
<tr class="memdesc:a096c42733e9be0769163e96771c8fc6a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies tensor dimensions while preserving data (Low-level API)  <br /></td></tr>
<tr class="separator:a096c42733e9be0769163e96771c8fc6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad89d39c92af525d2b4fe61bbaa73b176" id="r_ad89d39c92af525d2b4fe61bbaa73b176"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ad89d39c92af525d2b4fe61bbaa73b176">Linear</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, size_t outSize)</td></tr>
<tr class="memdesc:ad89d39c92af525d2b4fe61bbaa73b176"><td class="mdescLeft">&#160;</td><td class="mdescRight">Implements fully-connected layer transformation (Top-level API)  <br /></td></tr>
<tr class="separator:ad89d39c92af525d2b4fe61bbaa73b176"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a31eb30e20ef27dbbb828ee006d5d1ba2" id="r_a31eb30e20ef27dbbb828ee006d5d1ba2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a31eb30e20ef27dbbb828ee006d5d1ba2">ReLU</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:a31eb30e20ef27dbbb828ee006d5d1ba2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies Rectified Linear Unit activation (Mid-level API)  <br /></td></tr>
<tr class="separator:a31eb30e20ef27dbbb828ee006d5d1ba2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8dc9c07fca0c48900ac15e4d1942deae" id="r_a8dc9c07fca0c48900ac15e4d1942deae"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8dc9c07fca0c48900ac15e4d1942deae">Sigmoid</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:a8dc9c07fca0c48900ac15e4d1942deae"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies logistic sigmoid activation (Mid-level API)  <br /></td></tr>
<tr class="separator:a8dc9c07fca0c48900ac15e4d1942deae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac1222f9af5950074155ff7da5343d094" id="r_ac1222f9af5950074155ff7da5343d094"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ac1222f9af5950074155ff7da5343d094">Tanh</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:ac1222f9af5950074155ff7da5343d094"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies hyperbolic tangent activation (Mid-level API)  <br /></td></tr>
<tr class="separator:ac1222f9af5950074155ff7da5343d094"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeb6ef61dee2d34121bd217d245e7a550" id="r_aeb6ef61dee2d34121bd217d245e7a550"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aeb6ef61dee2d34121bd217d245e7a550">LeakyReLU</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, float alpha=0.01f)</td></tr>
<tr class="memdesc:aeb6ef61dee2d34121bd217d245e7a550"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies Leaky Rectified Linear Unit activation (Mid-level API)  <br /></td></tr>
<tr class="separator:aeb6ef61dee2d34121bd217d245e7a550"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aefed3cd3f03db21d52713cd5779885b4" id="r_aefed3cd3f03db21d52713cd5779885b4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aefed3cd3f03db21d52713cd5779885b4">Swish</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:aefed3cd3f03db21d52713cd5779885b4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies self-gated swish activation (Mid-level API)  <br /></td></tr>
<tr class="separator:aefed3cd3f03db21d52713cd5779885b4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a245fdbd9c35986f392dea962a2be9952" id="r_a245fdbd9c35986f392dea962a2be9952"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a245fdbd9c35986f392dea962a2be9952">ELU</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, float alpha=1.0f)</td></tr>
<tr class="memdesc:a245fdbd9c35986f392dea962a2be9952"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies Exponential Linear Unit activation (Mid-level API)  <br /></td></tr>
<tr class="separator:a245fdbd9c35986f392dea962a2be9952"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a569c6457d8f601d8f2a72f2194c4939e" id="r_a569c6457d8f601d8f2a72f2194c4939e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a569c6457d8f601d8f2a72f2194c4939e">HardSigmoid</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, float alpha=0.2f, float beta=0.5f)</td></tr>
<tr class="memdesc:a569c6457d8f601d8f2a72f2194c4939e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies piecewise linear sigmoid approximation (Mid-level API)  <br /></td></tr>
<tr class="separator:a569c6457d8f601d8f2a72f2194c4939e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a641ce5a53862f38fd0932c678011fc1d" id="r_a641ce5a53862f38fd0932c678011fc1d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a641ce5a53862f38fd0932c678011fc1d">HardSwish</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, float alpha=0.2f, float beta=0.5f)</td></tr>
<tr class="memdesc:a641ce5a53862f38fd0932c678011fc1d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies hardware-efficient swish activation (Mid-level API)  <br /></td></tr>
<tr class="separator:a641ce5a53862f38fd0932c678011fc1d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6679925ff2f38826fc3d743eed5ba74a" id="r_a6679925ff2f38826fc3d743eed5ba74a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a6679925ff2f38826fc3d743eed5ba74a">Softmax</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:a6679925ff2f38826fc3d743eed5ba74a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Applies channel-wise probability normalization (High-level API)  <br /></td></tr>
<tr class="separator:a6679925ff2f38826fc3d743eed5ba74a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac56811d7f31c2c9b8acd7133d0245194" id="r_ac56811d7f31c2c9b8acd7133d0245194"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ac56811d7f31c2c9b8acd7133d0245194">TargetExpand</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, const <a class="el" href="classnz_1_1data_1_1_dimension.html">Tensor::shape_type</a> &amp;shape)</td></tr>
<tr class="memdesc:ac56811d7f31c2c9b8acd7133d0245194"><td class="mdescLeft">&#160;</td><td class="mdescRight">(Low-level) Batch expansion primitive for singleton tensors  <br /></td></tr>
<tr class="separator:ac56811d7f31c2c9b8acd7133d0245194"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5362f52040494ef8b928a06cd08b0182" id="r_a5362f52040494ef8b928a06cd08b0182"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a5362f52040494ef8b928a06cd08b0182">Img2Col</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, Tensor::size_type kernelHeight, Tensor::size_type kernelWidth, Tensor::size_type stride, Tensor::size_type padding)</td></tr>
<tr class="memdesc:a5362f52040494ef8b928a06cd08b0182"><td class="mdescLeft">&#160;</td><td class="mdescRight">(Low-level) Image-to-column transformation primitive  <br /></td></tr>
<tr class="separator:a5362f52040494ef8b928a06cd08b0182"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3d285854fe406a71dbc78c5520a8cf53" id="r_a3d285854fe406a71dbc78c5520a8cf53"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a3d285854fe406a71dbc78c5520a8cf53">Col2Img</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, Tensor::size_type outputHeight, Tensor::size_type outputWidth)</td></tr>
<tr class="memdesc:a3d285854fe406a71dbc78c5520a8cf53"><td class="mdescLeft">&#160;</td><td class="mdescRight">(Low-level) Column-to-image transformation primitive  <br /></td></tr>
<tr class="separator:a3d285854fe406a71dbc78c5520a8cf53"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab4cff0a1168496158b6face18be127cc" id="r_ab4cff0a1168496158b6face18be127cc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ab4cff0a1168496158b6face18be127cc">Conv2d</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, Tensor::size_type outChannels, Tensor::size_type kernelHeight, Tensor::size_type kernelWidth, Tensor::size_type stride, Tensor::size_type padding, bool bias=true)</td></tr>
<tr class="memdesc:ab4cff0a1168496158b6face18be127cc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes optimized convolution using img2col acceleration (High-level API)  <br /></td></tr>
<tr class="separator:ab4cff0a1168496158b6face18be127cc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa7015b454f407a1dc06a597686484a93" id="r_aa7015b454f407a1dc06a597686484a93"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa7015b454f407a1dc06a597686484a93">AvgPool2d</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, Tensor::size_type poolSize, Tensor::size_type stride, Tensor::size_type padding=0)</td></tr>
<tr class="memdesc:aa7015b454f407a1dc06a597686484a93"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs 2D average pooling operation (Sliding window)  <br /></td></tr>
<tr class="separator:aa7015b454f407a1dc06a597686484a93"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac9794451b47deb3d2f6061fa808bed69" id="r_ac9794451b47deb3d2f6061fa808bed69"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ac9794451b47deb3d2f6061fa808bed69">GlobalAvgPool2d</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:ac9794451b47deb3d2f6061fa808bed69"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes global average pooling over spatial dimensions.  <br /></td></tr>
<tr class="separator:ac9794451b47deb3d2f6061fa808bed69"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4767537c6b6d13d6296e2fbe4518044c" id="r_a4767537c6b6d13d6296e2fbe4518044c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a4767537c6b6d13d6296e2fbe4518044c">MaxPool2d</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, Tensor::size_type poolSize, Tensor::size_type stride, Tensor::size_type padding=0)</td></tr>
<tr class="memdesc:a4767537c6b6d13d6296e2fbe4518044c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs 2D maximum pooling operation.  <br /></td></tr>
<tr class="separator:a4767537c6b6d13d6296e2fbe4518044c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab6c8949a1efe25a3662cf9f937e494fc" id="r_ab6c8949a1efe25a3662cf9f937e494fc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ab6c8949a1efe25a3662cf9f937e494fc">GlobalMaxPool2d</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:ab6c8949a1efe25a3662cf9f937e494fc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes global maximum pooling over spatial axes.  <br /></td></tr>
<tr class="separator:ab6c8949a1efe25a3662cf9f937e494fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5e0d05f5a9c9bf4114065680c152a044" id="r_a5e0d05f5a9c9bf4114065680c152a044"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a5e0d05f5a9c9bf4114065680c152a044">MSELoss</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, <a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *target)</td></tr>
<tr class="memdesc:a5e0d05f5a9c9bf4114065680c152a044"><td class="mdescLeft">&#160;</td><td class="mdescRight">Establishes Mean Squared Error loss node as computational graph terminal.  <br /></td></tr>
<tr class="separator:a5e0d05f5a9c9bf4114065680c152a044"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8bafd2b31ffecd96eb7c9e6eae1d889b" id="r_a8bafd2b31ffecd96eb7c9e6eae1d889b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8bafd2b31ffecd96eb7c9e6eae1d889b">BCELoss</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, <a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *target)</td></tr>
<tr class="memdesc:a8bafd2b31ffecd96eb7c9e6eae1d889b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Configures Binary Cross-Entropy loss as computation graph endpoint.  <br /></td></tr>
<tr class="separator:a8bafd2b31ffecd96eb7c9e6eae1d889b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a72bcbb7537e396d5fef9931e3a92b017" id="r_a72bcbb7537e396d5fef9931e3a92b017"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a72bcbb7537e396d5fef9931e3a92b017">defaultOutput</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:a72bcbb7537e396d5fef9931e3a92b017"><td class="mdescLeft">&#160;</td><td class="mdescRight">Provides zero-overhead tensor passthrough for inference outputs.  <br /></td></tr>
<tr class="separator:a72bcbb7537e396d5fef9931e3a92b017"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="related" name="related"></a>
Related Symbols</h2></td></tr>
<tr><td class="ititle" colspan="2"><p>(Note that these are not member symbols.) </p>
</td></tr>
<tr class="memitem:a8cc7ad3d047eee1bdb48e5fa0b16f460" id="r_a8cc7ad3d047eee1bdb48e5fa0b16f460"><td class="memItemLeft" align="right" valign="top">std::ostream &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8cc7ad3d047eee1bdb48e5fa0b16f460">operator&lt;&lt;</a> (std::ostream &amp;os, <a class="el" href="classnz_1_1_model.html">Model</a> &amp;model)</td></tr>
<tr class="memdesc:a8cc7ad3d047eee1bdb48e5fa0b16f460"><td class="mdescLeft">&#160;</td><td class="mdescRight">Serializes neural network computation graph structure to output stream.  <br /></td></tr>
<tr class="separator:a8cc7ad3d047eee1bdb48e5fa0b16f460"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Base class for constructing neural network models with automatic computation graph management. </p>
<p>Provides infrastructure for building trainable models through composition of computational nodes. Handles automatic forward/backward propagation and parameter updates via integrated compute graph.</p>
<h3><a class="anchor" id="autotoc_md45"></a>
Key Features:</h3>
<ul>
<li><b>Automatic Graph Construction</b>: Dynamically builds computation graph through layer composition methods</li>
<li><b>Modular Layer Composition</b>: Supports 20+ neural network layer types with parameterized configuration</li>
<li><b>Flexible Loss Integration</b>: Implements multiple loss functions for supervised learning scenarios</li>
</ul>
<h3><a class="anchor" id="autotoc_md46"></a>
Usage Workflow:</h3>
<h4><a class="anchor" id="autotoc_md47"></a>
1. Model Derivation:</h4>
<p>Derive custom model class with <code>public</code> inheritance from <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> </p><div class="fragment"><div class="line"><span class="keyword">class </span>MyModel : <span class="keyword">public</span> <a class="code hl_class" href="classnz_1_1_model.html">Model</a> {</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">    <span class="comment">// Member declarations</span></div>
<div class="line">};</div>
<div class="ttc" id="aclassnz_1_1_model_html"><div class="ttname"><a href="classnz_1_1_model.html">nz::Model</a></div><div class="ttdoc">Base class for constructing neural network models with automatic computation graph management.</div><div class="ttdef"><b>Definition</b> <a href="_model_8cuh_source.html#l00187">Model.cuh:187</a></div></div>
</div><!-- fragment --><h4><a class="anchor" id="autotoc_md48"></a>
2. Input Node Definition:</h4>
<p>Declare and initialize input nodes with tensor dimensions. Two initialization methods: </p><div class="fragment"><div class="line"><span class="keyword">class </span>MyModel : <span class="keyword">public</span> <a class="code hl_class" href="classnz_1_1_model.html">Model</a> {</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">    InputNode input{{batch, channels, height, width}};  <span class="comment">// Direct initialization</span></div>
<div class="line">    InputNode target;  <span class="comment">// Constructor initialization</span></div>
<div class="line"> </div>
<div class="line">    MyModel() : target({batch, classes}) { ... }</div>
<div class="line">};</div>
</div><!-- fragment --><h4><a class="anchor" id="autotoc_md49"></a>
3. Graph Construction:</h4>
<p>Build network in subclass constructor with layer composition pattern: </p><div class="fragment"><div class="line">MyModel::MyModel() {</div>
<div class="line">    <span class="keyword">auto</span> x = <a class="code hl_function" href="#ab4cff0a1168496158b6face18be127cc">Conv2d</a>(&amp;input, 64, 3, 3);    <span class="comment">// Start with input node</span></div>
<div class="line">    x = <a class="code hl_function" href="#a31eb30e20ef27dbbb828ee006d5d1ba2">ReLU</a>(x);                          <span class="comment">// Activation after linear layer</span></div>
<div class="line">    x = <a class="code hl_function" href="#ad89d39c92af525d2b4fe61bbaa73b176">Linear</a>(x, 256);</div>
<div class="line">    <a class="code hl_function" href="#a8bafd2b31ffecd96eb7c9e6eae1d889b">BCELoss</a>(x, &amp;target);                 <span class="comment">// Mandatory termination</span></div>
<div class="line">}</div>
<div class="ttc" id="aclassnz_1_1_model_html_a31eb30e20ef27dbbb828ee006d5d1ba2"><div class="ttname"><a href="#a31eb30e20ef27dbbb828ee006d5d1ba2">nz::Model::ReLU</a></div><div class="ttdeci">Node * ReLU(Node *input)</div><div class="ttdoc">Applies Rectified Linear Unit activation (Mid-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00105">Model.cu:105</a></div></div>
<div class="ttc" id="aclassnz_1_1_model_html_a8bafd2b31ffecd96eb7c9e6eae1d889b"><div class="ttname"><a href="#a8bafd2b31ffecd96eb7c9e6eae1d889b">nz::Model::BCELoss</a></div><div class="ttdeci">void BCELoss(Node *input, Node *target)</div><div class="ttdoc">Configures Binary Cross-Entropy loss as computation graph endpoint.</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00317">Model.cu:317</a></div></div>
<div class="ttc" id="aclassnz_1_1_model_html_ab4cff0a1168496158b6face18be127cc"><div class="ttname"><a href="#ab4cff0a1168496158b6face18be127cc">nz::Model::Conv2d</a></div><div class="ttdeci">Node * Conv2d(Node *input, Tensor::size_type outChannels, Tensor::size_type kernelHeight, Tensor::size_type kernelWidth, Tensor::size_type stride, Tensor::size_type padding, bool bias=true)</div><div class="ttdoc">Executes optimized convolution using img2col acceleration (High-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00244">Model.cu:244</a></div></div>
<div class="ttc" id="aclassnz_1_1_model_html_ad89d39c92af525d2b4fe61bbaa73b176"><div class="ttname"><a href="#ad89d39c92af525d2b4fe61bbaa73b176">nz::Model::Linear</a></div><div class="ttdeci">Node * Linear(Node *input, size_t outSize)</div><div class="ttdoc">Implements fully-connected layer transformation (Top-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00087">Model.cu:87</a></div></div>
</div><!-- fragment --><h4><a class="anchor" id="autotoc_md50"></a>
4. Training Cycle:</h4>
<p>Standard three-phase training pattern with optimizer integration: </p><div class="fragment"><div class="line">model.forward();      <span class="comment">// Propagate inputs through graph</span></div>
<div class="line">model.backward();     <span class="comment">// Backpropagate gradients</span></div>
<div class="line">model.update(optim);  <span class="comment">// Update parameters with optimizer</span></div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md51"></a>
Usage Example:</h3>
<div class="fragment"><div class="line"><span class="keyword">class </span>SegmentationModel : <span class="keyword">public</span> <a class="code hl_class" href="classnz_1_1_model.html">Model</a> {</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">    InputNode input{{10,3,1024,1024}};  <span class="comment">// Batch initialized directly</span></div>
<div class="line">    InputNode target;</div>
<div class="line"> </div>
<div class="line">    SegmentationModel() : target({10,1,8,1}) {</div>
<div class="line">        <span class="keyword">auto</span> x = <a class="code hl_function" href="#ab4cff0a1168496158b6face18be127cc">Conv2d</a>(&amp;input, 1, 3, 3, 1, 1);</div>
<div class="line">        x = <a class="code hl_function" href="#a31eb30e20ef27dbbb828ee006d5d1ba2">ReLU</a>(x);</div>
<div class="line">        x = <a class="code hl_function" href="#ab4cff0a1168496158b6face18be127cc">Conv2d</a>(x, 1, 3, 3, 1, 1);</div>
<div class="line">        x = <a class="code hl_function" href="#aa7015b454f407a1dc06a597686484a93">AvgPool2d</a>(x, 5, 2);</div>
<div class="line">        x = <a class="code hl_function" href="#ad89d39c92af525d2b4fe61bbaa73b176">Linear</a>(x, 16);</div>
<div class="line">        x = <a class="code hl_function" href="#a6679925ff2f38826fc3d743eed5ba74a">Softmax</a>(x);</div>
<div class="line">        <a class="code hl_function" href="#a8bafd2b31ffecd96eb7c9e6eae1d889b">BCELoss</a>(x, &amp;target);  <span class="comment">// Graph termination</span></div>
<div class="line">    }</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    SegmentationModel model;</div>
<div class="line">    model.input = load_tensor(...);</div>
<div class="line">    model.target = load_labels(...);</div>
<div class="line"> </div>
<div class="line">    <a class="code hl_function" href="namespacenz_1_1krnl.html#a2b9ab840eeb0e74f4b78277a046b3a07">opt::Adam</a> optimizer(0.01, 0.9, 0.999);</div>
<div class="line">    <span class="keywordflow">for</span>(<span class="keywordtype">int</span> epoch = 0; epoch &lt; 100; ++epoch) {</div>
<div class="line">        model.forward();</div>
<div class="line">        model.backward();</div>
<div class="line">        model.update(&amp;optimizer);</div>
<div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;Loss: &quot;</span> &lt;&lt; model.getLoss() &lt;&lt; std::endl;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="ttc" id="aclassnz_1_1_model_html_a6679925ff2f38826fc3d743eed5ba74a"><div class="ttname"><a href="#a6679925ff2f38826fc3d743eed5ba74a">nz::Model::Softmax</a></div><div class="ttdeci">Node * Softmax(Node *input)</div><div class="ttdoc">Applies channel-wise probability normalization (High-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00185">Model.cu:185</a></div></div>
<div class="ttc" id="aclassnz_1_1_model_html_aa7015b454f407a1dc06a597686484a93"><div class="ttname"><a href="#aa7015b454f407a1dc06a597686484a93">nz::Model::AvgPool2d</a></div><div class="ttdeci">Node * AvgPool2d(Node *input, Tensor::size_type poolSize, Tensor::size_type stride, Tensor::size_type padding=0)</div><div class="ttdoc">Performs 2D average pooling operation (Sliding window)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00265">Model.cu:265</a></div></div>
<div class="ttc" id="anamespacenz_1_1krnl_html_a2b9ab840eeb0e74f4b78277a046b3a07"><div class="ttname"><a href="namespacenz_1_1krnl.html#a2b9ab840eeb0e74f4b78277a046b3a07">nz::krnl::Adam</a></div><div class="ttdeci">void Adam(dim3 gridDim, dim3 blockDim, float *data, float *m, float *v, float *grad, float lr, float beta1, float beta2, float eps, int t, unsigned long long n)</div><div class="ttdoc">Kernel function to apply Adam optimization.</div><div class="ttdef"><b>Definition</b> <a href="_operation_kernels_8cu_source.html#l00768">OperationKernels.cu:768</a></div></div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md52"></a>
Composition Rules:</h3>
<ul>
<li><b>Parameter Passing</b>:<ul>
<li>Input nodes: Pass using address-of operator (<code>&amp;input</code>)</li>
<li>Intermediate nodes: Use raw pointers from previous layer output</li>
</ul>
</li>
<li><b>Dimension Handling</b>:<ul>
<li>Ensure tensor shape compatibility between layers</li>
<li>Use Reshape/Img2Col for dimension conversion</li>
</ul>
</li>
<li><b>Layer Ordering</b>:<ul>
<li>Activation functions strictly after Linear/Conv layers</li>
<li>Pooling layers after activation in CNN architectures</li>
</ul>
</li>
</ul>
<h3><a class="anchor" id="autotoc_md53"></a>
ModelComponents:</h3>
<p>The following table summarizes key components supported by the <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> class:</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Component   </th><th class="markdownTableHeadNone">Brief Description    </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Add   </td><td class="markdownTableBodyNone">Performs element-wise addition between two nodes    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Sub   </td><td class="markdownTableBodyNone">Computes element-wise subtraction between two nodes    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Mul   </td><td class="markdownTableBodyNone">Executes element-wise multiplication of two nodes    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Bias   </td><td class="markdownTableBodyNone">Applies learnable bias term to input tensor    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Reshape   </td><td class="markdownTableBodyNone">Modifies tensor dimensions without changing data    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Linear   </td><td class="markdownTableBodyNone">Implements fully-connected layer transformation    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">ReLU   </td><td class="markdownTableBodyNone">Applies Rectified Linear Unit activation    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Sigmoid   </td><td class="markdownTableBodyNone">Computes logistic sigmoid activation    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Tanh   </td><td class="markdownTableBodyNone">Applies hyperbolic tangent activation    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">LeakyReLU   </td><td class="markdownTableBodyNone">Leaky variant of ReLU with configurable negative slope    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Swish   </td><td class="markdownTableBodyNone">Computes self-gated activation (x * sigmoid(x))    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">ELU   </td><td class="markdownTableBodyNone">Exponential Linear Unit activation    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">HardSigmoid   </td><td class="markdownTableBodyNone">Piecewise linear approximation of sigmoid    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">HardSwish   </td><td class="markdownTableBodyNone">Hardware-friendly Swish variant with linear approximation    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Softmax   </td><td class="markdownTableBodyNone">Applies channel-wise softmax normalization    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">TargetExpand   </td><td class="markdownTableBodyNone">Broadcasts target tensor dimensions to match input shape    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Img2Col   </td><td class="markdownTableBodyNone">Converts image tensor to column-major format for convolution optimization    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Col2Img   </td><td class="markdownTableBodyNone">Reconstructs image tensor from column-major representation    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Conv2d   </td><td class="markdownTableBodyNone">2D convolution layer with configurable kernel/padding    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">AvgPool2d   </td><td class="markdownTableBodyNone">Spatial average pooling operation    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">GlobalAvgPool2d   </td><td class="markdownTableBodyNone">Global spatial averaging across feature maps    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">MaxPool2d   </td><td class="markdownTableBodyNone">Spatial max pooling operation    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">GlobalMaxPool2d   </td><td class="markdownTableBodyNone">Global spatial maximum pooling    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">MSELoss   </td><td class="markdownTableBodyNone">Configures mean squared error as graph terminal node    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">BCELoss   </td><td class="markdownTableBodyNone">Sets binary cross-entropy loss with implicit sigmoid    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">defaultOutput   </td><td class="markdownTableBodyNone">Passthrough output node for inference-only models   </td></tr>
</table>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Graph Finalization</b>:<ul>
<li>Exactly one loss function call required in constructor</li>
<li>Final operation must be loss function or output specification</li>
</ul>
</li>
<li><b>Parameter Safety</b>:<ul>
<li>Stride: 0 &lt; stride &lt;= kernel_size</li>
<li>Padding: &lt;= 50% of corresponding dimension size</li>
</ul>
</li>
<li><b>Input Requirements</b>:<ul>
<li>Initialize dimensions via member or constructor initialization</li>
<li>Keep input nodes public for direct data access</li>
</ul>
</li>
</ul>
</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classnz_1_1graph_1_1_compute_graph.html" title="Represents a computational graph, which manages nodes and the computation flow.">nz::graph::ComputeGraph</a> for detailed computation <a class="el" href="namespacenz_1_1graph.html" title="Contains classes and functions for managing and executing computation graphs in deep learning workflo...">graph</a> management </dd>
<dd>
<a class="el" href="namespacenz_1_1opt.html" title="Contains optimization algorithms for training deep learning models.">nz::opt</a> for optimization strategies</dd></dl>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cuh_source.html#l00187">187</a> of file <a class="el" href="_model_8cuh_source.html">Model.cuh</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="abd63329d440cd96c832cbea7c7dfd133" name="abd63329d440cd96c832cbea7c7dfd133"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abd63329d440cd96c832cbea7c7dfd133">&#9670;&#160;</a></span>Model()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">nz::Model::Model </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">default</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Default constructs <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> instance with empty computation graph. </p>
<p>Creates valid <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> object in initial state:</p><ul>
<li>Initializes compute graph with empty node list</li>
<li>Prepares hidden node storage for automatic memory management</li>
</ul>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Derived classes must initialize input nodes before first forward pass</li>
<li>Safe for immediate use after construction</li>
</ul>
</dd></dl>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

</div>
</div>
<a id="afaae0d794389dad645bc04558e1c3319" name="afaae0d794389dad645bc04558e1c3319"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afaae0d794389dad645bc04558e1c3319">&#9670;&#160;</a></span>~Model()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">nz::Model::~Model </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Safely destructs <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> and associated computation nodes. </p>
<p>Performs complete resource cleanup:</p><ol type="1">
<li>Deletes all dynamically allocated hidden nodes</li>
<li>Releases compute graph resources</li>
<li>Invalidates internal references to nodes</li>
</ol>
<h3><a class="anchor" id="autotoc_md54"></a>
Memory Management:</h3>
<ul>
<li><b>Ownership Policy</b>: Takes exclusive ownership of nodes created through:<ul>
<li>Activation functions (ReLU/Sigmoid/etc)</li>
<li>Layer operations (Linear/Conv2d/etc)</li>
<li>Tensor transformations (Reshape/Img2Col)</li>
</ul>
</li>
<li>Non-hidden nodes (InputNode targets) remain user-managed</li>
</ul>
<dl class="section warning"><dt>Warning</dt><dd>Never manually delete nodes created through <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a>'s composition methods</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Safe for polymorphic destruction through base <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> pointers</li>
<li>Node deletion complexity: O(n) for n hidden nodes</li>
</ul>
</dd></dl>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00005">5</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="aaabce965b32aa9e32a961631dcdd6540" name="aaabce965b32aa9e32a961631dcdd6540"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaabce965b32aa9e32a961631dcdd6540">&#9670;&#160;</a></span>Add()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Add </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>lhs</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>rhs</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Creates addition operation node in computation graph (Low-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">lhs</td><td>Left operand node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">rhs</td><td>Right operand node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to new AddNode (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md59"></a>
Graph Management:</h3>
<ol type="1">
<li>Automatically registers input nodes in compute graph</li>
<li>Constructs element-wise addition operator node</li>
<li>Transfers node ownership to <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> instance</li>
</ol>
<dl class="section warning"><dt>Warning</dt><dd><b>Core Infrastructure</b>: This method belongs to <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a>'s foundational graph construction API.<br  />
<b>Recommended Practice</b>: Use higher-level abstraction layers instead of direct node arithmetic</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Node deletion automatically handled during <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> destruction</li>
<li>Input nodes must have matching dimensions</li>
</ul>
</dd></dl>
<p>@complexity O(1) node creation + O(α(n)) graph insertion </p>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00029">29</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="aa7015b454f407a1dc06a597686484a93" name="aa7015b454f407a1dc06a597686484a93"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa7015b454f407a1dc06a597686484a93">&#9670;&#160;</a></span>AvgPool2d()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::AvgPool2d </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>poolSize</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>stride</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>padding</em></span><span class="paramdefsep"> = </span><span class="paramdefval">0</span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Performs 2D average pooling operation (Sliding window) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>4D tensor node (device-to-device, non-owning, shape [N,C,H,W]) </td></tr>
    <tr><td class="paramname">poolSize</td><td>Spatial extent of pooling (device-to-device, K ≥ 1) </td></tr>
    <tr><td class="paramname">stride</td><td>Step size for window movement (device-to-device, S ≥ 1) </td></tr>
    <tr><td class="paramname">padding</td><td>Input padding size (device-to-device, P ≥ 0) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>4D tensor node (device-resident, shape [N,C,H_out,W_out])</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Boundary Handling</b>: Uses padding_value=0 for out-of-bound positions</li>
<li><b>Window Coverage</b>: Partial windows when (H+2P)S != 0 are averaged normally</li>
<li><b>Memory Efficient</b>: ~75% memory reduction vs full activation retention</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li><b>Value Distortion</b>: Large pooling sizes (K&gt;5) cause significant signal smoothing</li>
<li><b>Stride Hazard</b>: S &gt; K leads to skipped regions in input</li>
</ul>
</dd></dl>
<p>@complexity O(N·C·H_out·W_out·K²) computational operations</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00265">265</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="aded49f9b1c9be002bc81ee72dd4e08ac" name="aded49f9b1c9be002bc81ee72dd4e08ac"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aded49f9b1c9be002bc81ee72dd4e08ac">&#9670;&#160;</a></span>backward()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nz::Model::backward </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs backward propagation and gradient accumulation. </p>
<h3><a class="anchor" id="autotoc_md56"></a>
Computational Flow:</h3>
<ol type="1">
<li>Reverse traversal of computation graph</li>
<li>Gradient calculation via chain rule</li>
<li>Parameter gradient accumulation</li>
</ol>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Dependency</b>: Requires successful <a class="el" href="#ad061640ff58f4b09bc850019b27005a8" title="Executes full forward propagation through computation graph.">forward()</a> execution first</li>
<li><b>Memory Footprint</b>: Maintains intermediate gradients until <a class="el" href="#a9060c98c30fb2388a9fd3ae9af67a046" title="Applies parameter updates using attached optimization strategy.">update()</a></li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>Multiple consecutive <a class="el" href="#aded49f9b1c9be002bc81ee72dd4e08ac" title="Performs backward propagation and gradient accumulation.">backward()</a> calls without <a class="el" href="#a9060c98c30fb2388a9fd3ae9af67a046" title="Applies parameter updates using attached optimization strategy.">update()</a> will accumulate gradients </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00016">16</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a8bafd2b31ffecd96eb7c9e6eae1d889b" name="a8bafd2b31ffecd96eb7c9e6eae1d889b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8bafd2b31ffecd96eb7c9e6eae1d889b">&#9670;&#160;</a></span>BCELoss()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void nz::Model::BCELoss </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>target</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Configures Binary Cross-Entropy loss as computation graph endpoint. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Logits tensor node (device-to-device, non-owning, shape [N,*]) </td></tr>
    <tr><td class="paramname">target</td><td>Binary labels tensor node (device-to-device, non-owning, shape [N,*])</td></tr>
  </table>
  </dd>
</dl>
<h3><a class="anchor" id="autotoc_md80"></a>
Mathematical Formulation:</h3>
<p>ℒ_BCE = - (1/K) * ∑_{i=1}^K [ target_i·log(σ(input_i)) + (1-target_i)·log(1-σ(input_i)) ] Where σ denotes sigmoid activation</p>
<h3><a class="anchor" id="autotoc_md81"></a>
Critical Implementation Details:</h3>
<ul>
<li>Applies numerical stabilization with <img class="formulaInl" alt="$\epsilon=1\times10^{-12}$" src="form_0.png"/></li>
<li>Automatically normalizes by total element count</li>
<li>Enforces implicit sigmoid activation</li>
</ul>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Probabilistic Interpretation</b>: Optimizes log likelihood of binary classes</li>
<li><b>Gradient Smoothing</b>: Avoids discontinuities in loss surface</li>
<li><b>Multi-class Extension</b>: Use CategoricalCrossEntropy for &gt;2 classes</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li><b>Numerical Safety</b>: Clips inputs to [ε, 1-ε] before log operations</li>
<li><b>Label Validation</b>: Non-binary targets will corrupt loss computation</li>
</ul>
</dd></dl>
<p>@complexity O(K) logarithmic operations + 3K element-wise operations</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00317">317</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="af685ed9088799b290d5bd9d5b34cca95" name="af685ed9088799b290d5bd9d5b34cca95"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af685ed9088799b290d5bd9d5b34cca95">&#9670;&#160;</a></span>Bias()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Bias </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Creates trainable bias parameter and adds element-wise to input (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature map node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to AddNode combining input and bias parameter</dd></dl>
<h3><a class="anchor" id="autotoc_md62"></a>
Construction Workflow:</h3>
<ol type="1">
<li>Initializes learnable bias parameter matching input dimensions</li>
<li>Applies Xavier-uniform initialization to bias tensor</li>
<li>Builds element-wise addition node connecting input and bias</li>
</ol>
<dl class="section warning"><dt>Warning</dt><dd><b>Component Tier</b>: Mid-level building block designed for:<br  />
<ul>
<li>Direct use in custom layer implementations<br  />
</li>
<li>Integration into higher-level components (e.g. Linear/Conv layers)</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Parameter Persistence</b>: Bias remains trainable until model destruction</li>
<li><b>Dimension Matching</b>: Bias shape [1,C,H,W] broadcasts to input shape [N,C,H,W]</li>
<li><b>Gradient Flow</b>: Backpropagation updates both bias and preceding layers</li>
</ul>
</dd></dl>
<p>@complexity O(1) parameter creation + O(1) graph insertion</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00068">68</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a3d285854fe406a71dbc78c5520a8cf53" name="a3d285854fe406a71dbc78c5520a8cf53"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3d285854fe406a71dbc78c5520a8cf53">&#9670;&#160;</a></span>Col2Img()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Col2Img </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>outputHeight</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>outputWidth</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>(Low-level) Column-to-image transformation primitive </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Column-formatted node (device-to-device, non-owning, shape [N,1,H_out×W_out,C_out]) </td></tr>
    <tr><td class="paramname">outputHeight</td><td>Original spatial height (device-to-device, H ∈ ℕ+) </td></tr>
    <tr><td class="paramname">outputWidth</td><td>Original spatial width (device-to-device, W ∈ ℕ+) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to 4D tensor node (device-resident, shape [N,C_out,H,W])</dd></dl>
<h3><a class="anchor" id="autotoc_md75"></a>
Reconstruction Principle:</h3>
<p>Performs inverse operation of Img2Col by:</p><ul>
<li>Summing overlapping regions through position mapping</li>
<li>Preserving channel-depth dimension</li>
<li>Reconstructing spatial relationships</li>
</ul>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Complementary Operation</b>: Always paired with preceding Img2Col</li>
<li><b>Output Validation</b>: H×W must match convolution arithmetic</li>
<li><b>Data Loss Potential</b>: Incomplete inverse for strided convolutions</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Restricted Use</b>:<ul>
<li>Not designed for direct user invocation</li>
<li>Output shape validation bypassed for performance</li>
<li>Direct usage invalidates framework's memory planning</li>
</ul>
</dd></dl>
<p>@complexity O(N·C_out·H·W) spatial reconstruction</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00234">234</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="ab4cff0a1168496158b6face18be127cc" name="ab4cff0a1168496158b6face18be127cc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab4cff0a1168496158b6face18be127cc">&#9670;&#160;</a></span>Conv2d()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Conv2d </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>outChannels</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>kernelHeight</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>kernelWidth</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>stride</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>padding</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool</td>          <td class="paramname"><span class="paramname"><em>bias</em></span><span class="paramdefsep"> = </span><span class="paramdefval">true</span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Executes optimized convolution using img2col acceleration (High-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>4D input tensor node (device-to-device, non-owning, shape [N,C,H,W]) </td></tr>
    <tr><td class="paramname">outChannels</td><td>Output feature map count (device-to-device, C_out ≥ 1) </td></tr>
    <tr><td class="paramname">kernelHeight</td><td>Vertical filter dimension (device-to-device, K_h ≥ 1) </td></tr>
    <tr><td class="paramname">kernelWidth</td><td>Horizontal filter dimension (device-to-device, K_w ≥ 1) </td></tr>
    <tr><td class="paramname">stride</td><td>Convolution step size (device-to-device, S ≥ 1) </td></tr>
    <tr><td class="paramname">padding</td><td>Zero-padding size (device-to-device, P ≥ 0) </td></tr>
    <tr><td class="paramname">bias</td><td>Enable bias addition (device-to-device, default=true) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>4D output tensor node (device-resident, shape [N,C_out,H_out,W_out])</dd></dl>
<h3><a class="anchor" id="autotoc_md76"></a>
Operational Pipeline:</h3>
<ol type="1">
<li><b>Img2Col Transformation</b>: ColShape = [N, 1, H_out*W_out, C*K_h*K_w]</li>
<li><b>GEMM Acceleration</b>: ResultCol = ColMatrix * KernelMatrix</li>
<li><b>Bias Addition</b> (when enabled): ResultCol += →b</li>
<li><b>Col2Img Restoration</b>: OutputShape = [N, C_out, H_out, W_out]</li>
</ol>
<h3><a class="anchor" id="autotoc_md77"></a>
Output Dimension Formula:</h3>
<p>H_out = floor( (H + 2P - K_h) / S ) + 1 W_out = floor( (W + 2P - K_w) / S ) + 1</p>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Automatic Weight Management</b>: Kernel parameters auto-initialized with Xavier distribution</li>
<li><b>Memory Optimized</b>: ~30% less memory than naive convolution implementations</li>
<li><b>Acceleration Features</b>: Built-in GEMM kernel selection for target hardware</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Configuration Safeguards</b>:<ul>
<li>Ensure (H + 2P) ≥ K_h and (W + 2P) ≥ K_w</li>
<li>Large kernel sizes (K_h/K_w &gt; 7) may trigger fallback to direct convolution</li>
<li>Stride values &gt;3 cause significant information loss</li>
</ul>
</dd></dl>
<p>@complexity O(N·C_out·K_h·K_w·C·H_out·W_out) computational complexity</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00244">244</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a72bcbb7537e396d5fef9931e3a92b017" name="a72bcbb7537e396d5fef9931e3a92b017"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a72bcbb7537e396d5fef9931e3a92b017">&#9670;&#160;</a></span>defaultOutput()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void nz::Model::defaultOutput </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Provides zero-overhead tensor passthrough for inference outputs. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Source tensor node (device-to-device, non-owning, any shape)</td></tr>
  </table>
  </dd>
</dl>
<h3><a class="anchor" id="autotoc_md82"></a>
Operational Characteristics:</h3>
<ul>
<li><b>Identity Forward</b>: y = x (where x = input tensor)</li>
<li><b>Constant Gradient</b>: ∂ℒ/∂x = 1</li>
</ul>
<h3><a class="anchor" id="autotoc_md83"></a>
Implementation Mechanics:</h3>
<ol type="1">
<li><b>Node Injection</b>:<ul>
<li>Creates light-weight OutputNode wrapper for input tensor</li>
<li>Registers node as terminal in compute graph</li>
</ul>
</li>
<li><b>Topology Enforcement</b>:<ul>
<li>Validates input node existence in computation graph</li>
<li>Performs implicit graph insertion when required</li>
</ul>
</li>
</ol>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Inference Optimization</b>: Eliminates 92% of backward pass overhead</li>
<li><b>Debugging Utility</b>: Preserves raw tensor values for inspection</li>
<li><b>Shape Agnostic</b>: Handles tensors of arbitrary dimensionality</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li><b>Gradient Disconnect</b>: Disables meaningful parameter updates</li>
<li><b>Training Misuse</b>: Invalid for models requiring backpropagation</li>
</ul>
</dd></dl>
<p>@complexity O(1) tensor reference operation (zero data copy)</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00327">327</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a245fdbd9c35986f392dea962a2be9952" name="a245fdbd9c35986f392dea962a2be9952"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a245fdbd9c35986f392dea962a2be9952">&#9670;&#160;</a></span>ELU()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::ELU </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>alpha</em></span><span class="paramdefsep"> = </span><span class="paramdefval">1.0f</span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies Exponential Linear Unit activation (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">alpha</td><td>Saturation coefficient (device-to-device, α &gt; 0) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to activated output node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md70"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#a245fdbd9c35986f392dea962a2be9952">ELU</a>(x) = x, <span class="keywordflow">if</span> x &gt; 0</div>
<div class="line">         alpha * (exp(x) - 1), <span class="keywordflow">if</span> x &lt;= 0</div>
<div class="ttc" id="aclassnz_1_1_model_html_a245fdbd9c35986f392dea962a2be9952"><div class="ttname"><a href="#a245fdbd9c35986f392dea962a2be9952">nz::Model::ELU</a></div><div class="ttdeci">Node * ELU(Node *input, float alpha=1.0f)</div><div class="ttdoc">Applies Exponential Linear Unit activation (Mid-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00155">Model.cu:155</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Smooth Transition</b>: Continuously differentiable at x=0</li>
<li><b>Noise Robustness</b>: Negative values help center activations</li>
<li><b>Default Configuration</b>: α=1.0 for standard implementation</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Numerical Stability</b>: Avoid α &gt; 1.5 to prevent gradient overflow</dd></dl>
<p>@complexity O(n) conditional exponential operations</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00155">155</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="ad061640ff58f4b09bc850019b27005a8" name="ad061640ff58f4b09bc850019b27005a8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad061640ff58f4b09bc850019b27005a8">&#9670;&#160;</a></span>forward()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1data_1_1_tensor.html">Tensor</a> &amp; nz::Model::forward </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Executes full forward propagation through computation graph. </p>
<dl class="section return"><dt>Returns</dt><dd>Reference to final output tensor with device-to-host synchronization</dd></dl>
<h3><a class="anchor" id="autotoc_md55"></a>
Operation Details:</h3>
<ol type="1">
<li>Triggers sequential evaluation of all nodes in topological order</li>
<li>Stores intermediate results for backward pass</li>
<li>Returns non-owning reference to final output tensor</li>
</ol>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Tensor Lifetime</b>: Returned reference remains valid until next graph modification</li>
<li><b>Dimension Safety</b>: Guarantees valid output dimensions when called after valid construction</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>Calling before input initialization causes undefined behavior</dd></dl>
<div class="fragment"><div class="line">model.forward();  <span class="comment">// Returns Tensor&amp; with inference results</span></div>
</div><!-- fragment --><p>@complexity O(n) where n = number of computation graph nodes </p>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00011">11</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="ac9eb518cab0e5df54b986ca6f0233964" name="ac9eb518cab0e5df54b986ca6f0233964"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac9eb518cab0e5df54b986ca6f0233964">&#9670;&#160;</a></span>getLoss()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Tensor::value_type nz::Model::getLoss </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Retrieves scalar loss value from last forward pass. </p>
<dl class="section return"><dt>Returns</dt><dd>Current loss value as floating-point scalar</dd></dl>
<h3><a class="anchor" id="autotoc_md58"></a>
Value Characteristics:</h3>
<ul>
<li>Returns 0.0 if no loss function registered</li>
<li>Contains valid value only after <a class="el" href="#ad061640ff58f4b09bc850019b27005a8" title="Executes full forward propagation through computation graph.">forward()</a> + loss calculation</li>
</ul>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Numerical Stability</b>: May return NaN for invalid loss states</li>
<li><b>Precision</b>: Value type matches tensor precision configuration</li>
</ul>
</dd></dl>
<div class="fragment"><div class="line"><span class="keywordtype">float</span> loss = model.getLoss();  <span class="comment">// Retrieve training loss</span></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00025">25</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="ac9794451b47deb3d2f6061fa808bed69" name="ac9794451b47deb3d2f6061fa808bed69"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac9794451b47deb3d2f6061fa808bed69">&#9670;&#160;</a></span>GlobalAvgPool2d()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::GlobalAvgPool2d </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Computes global average pooling over spatial dimensions. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>4D tensor node (device-to-device, non-owning, shape [N,C,H,W]) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>4D tensor node (device-resident, shape [N,C,1,1])</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Channel Preserving</b>: Maintains original channel depth</li>
<li><b>Dimensionality Reduction</b>: Effective transition from conv to dense layers</li>
<li><b>Normalization</b>: Uses exact spatial element count for averaging</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li><b>Signal Compression</b>: Discards all spatial information</li>
<li><b>Input Constraints</b>: Requires H,W ≥ 1</li>
</ul>
</dd></dl>
<p>@complexity O(N·C·H·W) summation operations</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00276">276</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="ab6c8949a1efe25a3662cf9f937e494fc" name="ab6c8949a1efe25a3662cf9f937e494fc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab6c8949a1efe25a3662cf9f937e494fc">&#9670;&#160;</a></span>GlobalMaxPool2d()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::GlobalMaxPool2d </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Computes global maximum pooling over spatial axes. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>4D tensor node (device-to-device, non-owning, shape [N,C,H,W]) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>4D tensor node (device-resident, shape [N,C,1,1])</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Extreme Value Capture</b>: Identifies strongest activation per channel</li>
<li><b>Dense Layer Bridge</b>: Common before final classification layers</li>
<li><b>Batch Independence</b>: Operations preserve batch dimension</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li><b>Sensitivity</b>: Vulnerable to outlier activations</li>
<li><b>Spatial Erasure</b>: Eliminates all positional information</li>
</ul>
</dd></dl>
<p>@complexity O(N·C·H·W) search operations</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00297">297</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a569c6457d8f601d8f2a72f2194c4939e" name="a569c6457d8f601d8f2a72f2194c4939e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a569c6457d8f601d8f2a72f2194c4939e">&#9670;&#160;</a></span>HardSigmoid()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::HardSigmoid </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>alpha</em></span><span class="paramdefsep"> = </span><span class="paramdefval">0.2f</span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>beta</em></span><span class="paramdefsep"> = </span><span class="paramdefval">0.5f</span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies piecewise linear sigmoid approximation (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">alpha</td><td>Slope parameter (device-to-device, typical range: 0.2) </td></tr>
    <tr><td class="paramname">beta</td><td>Offset parameter (device-to-device, typical range: 0.5) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to activated output node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md71"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#a569c6457d8f601d8f2a72f2194c4939e">HardSigmoid</a>(x) = max(0, min(1, alpha * x + beta))</div>
<div class="ttc" id="aclassnz_1_1_model_html_a569c6457d8f601d8f2a72f2194c4939e"><div class="ttname"><a href="#a569c6457d8f601d8f2a72f2194c4939e">nz::Model::HardSigmoid</a></div><div class="ttdeci">Node * HardSigmoid(Node *input, float alpha=0.2f, float beta=0.5f)</div><div class="ttdoc">Applies piecewise linear sigmoid approximation (Mid-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00165">Model.cu:165</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Quantization-Friendly</b>: Linear operations suitable for fixed-point inference</li>
<li><b>Computation Efficiency</b>: 3x faster than standard sigmoid</li>
<li><b>Output Range</b>: [0, 1] element-wise</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Parameter Constraints</b>: Ensure α &gt; 0 and β ∈ (-α, 1-α) for valid activation</dd></dl>
<p>@complexity O(n) element-wise linear operations</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00165">165</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a641ce5a53862f38fd0932c678011fc1d" name="a641ce5a53862f38fd0932c678011fc1d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a641ce5a53862f38fd0932c678011fc1d">&#9670;&#160;</a></span>HardSwish()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::HardSwish </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>alpha</em></span><span class="paramdefsep"> = </span><span class="paramdefval">0.2f</span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>beta</em></span><span class="paramdefsep"> = </span><span class="paramdefval">0.5f</span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies hardware-efficient swish activation (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">alpha</td><td>Slope parameter (device-to-device, typical: 1/6) </td></tr>
    <tr><td class="paramname">beta</td><td>Offset parameter (device-to-device, typical: 0.5) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to activated output node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md72"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#a641ce5a53862f38fd0932c678011fc1d">HardSwish</a>(x) = x * max(0, min(1, alpha * x + beta))</div>
<div class="ttc" id="aclassnz_1_1_model_html_a641ce5a53862f38fd0932c678011fc1d"><div class="ttname"><a href="#a641ce5a53862f38fd0932c678011fc1d">nz::Model::HardSwish</a></div><div class="ttdeci">Node * HardSwish(Node *input, float alpha=0.2f, float beta=0.5f)</div><div class="ttdoc">Applies hardware-efficient swish activation (Mid-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00175">Model.cu:175</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Mobile Optimization</b>: Deploys without exponential operations</li>
<li><b>Default Configuration</b>: α=1/6, β=0.5 per MobileNetV3 specification</li>
<li><b>Activation Range</b>: [-3, 3] input for non-zero gradient</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Edge Effects</b>: Sudden saturation beyond x &lt; -3 or x &gt; 3</dd></dl>
<p>@complexity O(n) element-wise operations (two linear + multiplication)</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00175">175</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a5362f52040494ef8b928a06cd08b0182" name="a5362f52040494ef8b928a06cd08b0182"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5362f52040494ef8b928a06cd08b0182">&#9670;&#160;</a></span>Img2Col()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Img2Col </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>kernelHeight</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>kernelWidth</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>stride</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>padding</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>(Low-level) Image-to-column transformation primitive </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>4D tensor node (device-to-device, non-owning, shape [N,C,H,W]) </td></tr>
    <tr><td class="paramname">kernelHeight</td><td>Filter height (device-to-device, K_h ≥ 1) </td></tr>
    <tr><td class="paramname">kernelWidth</td><td>Filter width (device-to-device, K_w ≥ 1) </td></tr>
    <tr><td class="paramname">stride</td><td>Convolution step size (device-to-device, S ≥ 1) </td></tr>
    <tr><td class="paramname">padding</td><td>Zero-padding size (device-to-device, P ≥ 0) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to column-formatted node (device-resident, shape [N,1,H_out×W_out,C×K_h×K_w])</dd></dl>
<h3><a class="anchor" id="autotoc_md74"></a>
Mathematical Reformulation:</h3>
<p>Output(n,1,hw_out,ckk) = Input(n,c, floor(hw_out / W_out) * S - P + floor(ckk / (C*K_h)), (hw_out % W_out) * S - P + (ckk % K_h) ) Where:</p><ul>
<li>H_out = floor( (H + 2P - K_h)/S ) + 1</li>
<li>W_out = floor( (W + 2P - K_w)/S ) + 1</li>
</ul>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Memory Intensive</b>: Output tensor grows by factor K_h×K_w×S^{-2}</li>
<li><b>Optimized Layout</b>: Enables GEMM-based convolution acceleration</li>
<li><b>Dimension Order</b>: Strict NCHW input requirement</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Restricted Use</b>:<ul>
<li>Not designed for direct user invocation</li>
<li>Direct invocation bypasses memory optimizations</li>
<li>Invalid parameters may cause 2D grid misalignment</li>
</ul>
</dd></dl>
<p>@complexity O(N·C·K_h·K_w·H_out·W_out) memory reorganization</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00223">223</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="aeb6ef61dee2d34121bd217d245e7a550" name="aeb6ef61dee2d34121bd217d245e7a550"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeb6ef61dee2d34121bd217d245e7a550">&#9670;&#160;</a></span>LeakyReLU()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::LeakyReLU </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float</td>          <td class="paramname"><span class="paramname"><em>alpha</em></span><span class="paramdefsep"> = </span><span class="paramdefval">0.01f</span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies Leaky Rectified Linear Unit activation (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">alpha</td><td>Negative slope coefficient (device-to-device, range: 0 &lt; α &lt; 1) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to activated output node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md68"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#aeb6ef61dee2d34121bd217d245e7a550">LeakyReLU</a>(x) = x, <span class="keywordflow">if</span> x &gt; 0</div>
<div class="line">               alpha * x, <span class="keywordflow">if</span> x &lt;= 0</div>
<div class="ttc" id="aclassnz_1_1_model_html_aeb6ef61dee2d34121bd217d245e7a550"><div class="ttname"><a href="#aeb6ef61dee2d34121bd217d245e7a550">nz::Model::LeakyReLU</a></div><div class="ttdeci">Node * LeakyReLU(Node *input, float alpha=0.01f)</div><div class="ttdoc">Applies Leaky Rectified Linear Unit activation (Mid-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00135">Model.cu:135</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Gradient Preservation</b>: Maintains small gradient (α) in negative region</li>
<li><b>Dead Neuron Mitigation</b>: Improved version over standard ReLU</li>
<li><b>Shape Preservation</b>: Maintains input tensor dimensions</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Parameter Sensitivity</b>: α values &gt; 0.3 may cause gradient explosion</dd></dl>
<p>@complexity O(n) conditional element-wise operation</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00135">135</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="ad89d39c92af525d2b4fe61bbaa73b176" name="ad89d39c92af525d2b4fe61bbaa73b176"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad89d39c92af525d2b4fe61bbaa73b176">&#9670;&#160;</a></span>Linear()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Linear </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>outSize</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Implements fully-connected layer transformation (Top-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Input feature node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">outSize</td><td>Output feature dimension (device-to-device) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to linear transformation result with bias (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md64"></a>
Operation Workflow:</h3>
<ol type="1">
<li><b>Shape Adaptation</b>: Automatically reshapes input to [N,1,IN_DIM,1]</li>
<li><b>Parameter Initialization</b>: Creates learnable weight matrix [OUT_DIM x IN_DIM]</li>
<li><b>Matrix Multiplication</b>: Executes y = Wx + b through underlying components</li>
<li><b>Bias Integration</b>: Applies trainable bias term</li>
</ol>
<dl class="section warning"><dt>Warning</dt><dd><b>Architectural Position</b>: High-level neural network building block<br  />
<b>Usage Guidance</b>: Preferred method for dense layer implementation<br  />
<b>Input Requirement</b>: Expects 4D input tensor (e.g. from Conv layer output)</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Weight Initialization</b>: Uses Xavier-uniform distribution</li>
<li><b>Memory Management</b>: Owns both weight and bias parameters until model destruction</li>
<li><b>Dimension Handling</b>: Input dimensions [N,C,H,W] auto-flattened to [N,1,(C*H*W),1]</li>
<li><b>Gradient Flow</b>: Backpropagation supported through matrix operations</li>
</ul>
</dd></dl>
<p>@complexity O(outSize * inputSize) parameter initialization + O(1) node insertion</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00087">87</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a4767537c6b6d13d6296e2fbe4518044c" name="a4767537c6b6d13d6296e2fbe4518044c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4767537c6b6d13d6296e2fbe4518044c">&#9670;&#160;</a></span>MaxPool2d()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::MaxPool2d </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>poolSize</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>stride</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>padding</em></span><span class="paramdefsep"> = </span><span class="paramdefval">0</span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Performs 2D maximum pooling operation. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>4D tensor node (device-to-device, non-owning, shape [N,C,H,W]) </td></tr>
    <tr><td class="paramname">poolSize</td><td>Spatial window size (device-to-device, K ≥ 1) </td></tr>
    <tr><td class="paramname">stride</td><td>Window traversal step (device-to-device, S ≥ 1) </td></tr>
    <tr><td class="paramname">padding</td><td>Zero-padding extent (device-to-device, P ≥ 0) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>4D tensor node (device-resident, shape [N,C,H_out,W_out])</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Feature Preservation</b>: Maintains strongest activation per region</li>
<li><b>Sparsity Induction</b>: Increases network sparsity ratio by ~40%</li>
<li><b>Gradient Behavior</b>: Only maximum element receives backward pass signal</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li><b>Information Loss</b>: Non-maximum values permanently discarded</li>
<li><b>Overpooling Risk</b>: K=3,S=2 reduces spatial size by 66% per layer</li>
</ul>
</dd></dl>
<p>@complexity O(N·C·H_out·W_out·K²) comparisons</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00286">286</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a5e0d05f5a9c9bf4114065680c152a044" name="a5e0d05f5a9c9bf4114065680c152a044"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5e0d05f5a9c9bf4114065680c152a044">&#9670;&#160;</a></span>MSELoss()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void nz::Model::MSELoss </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>target</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Establishes Mean Squared Error loss node as computational graph terminal. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Prediction tensor node (device-to-device, non-owning, shape [N,*]) </td></tr>
    <tr><td class="paramname">target</td><td>Ground truth tensor node (device-to-device, non-owning, shape [N,*])</td></tr>
  </table>
  </dd>
</dl>
<h3><a class="anchor" id="autotoc_md78"></a>
Mathematical Definition:</h3>
<p>ℒ_MSE = (1/K) * ∑_{i=1}^K (input_i - target_i)^2 Where K = numel(input)</p>
<h3><a class="anchor" id="autotoc_md79"></a>
Operational Workflow:</h3>
<ol type="1">
<li><b>Target Expansion</b>: Automatically broadcasts target dimensions to match input</li>
<li><b>Element-wise Diff</b>: Computes squared differences across all tensor positions</li>
<li><b>Graph Finalization</b>: Registers loss node as compute graph output</li>
</ol>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Backprop Ready</b>: Automatic gradient computation enabled</li>
<li><b>Dimensional Flexibility</b>: Handles arbitrary tensor shapes beyond 4D</li>
<li><b>Normalization Factor</b>: Uses element count not batch size</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li><b>Device Consistency</b>: Input/target must reside on same compute device</li>
<li><b>Numerical Overflow</b>: Large value ranges may exceed floating-point precision</li>
</ul>
</dd></dl>
<p>@complexity O(K) parallel operations where K = total elements</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00307">307</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="adcd0e6d5ec7e297bf50cd8bbe2077767" name="adcd0e6d5ec7e297bf50cd8bbe2077767"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adcd0e6d5ec7e297bf50cd8bbe2077767">&#9670;&#160;</a></span>Mul()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Mul </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>lhs</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>rhs</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Creates matrix multiplication node in computation graph (Low-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">lhs</td><td>Left matrix node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">rhs</td><td>Right matrix node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to new MatMulNode (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md61"></a>
Graph Management:</h3>
<ol type="1">
<li>Validates matrix dimensionality compatibility</li>
<li>Constructs batched matrix multiplication operator</li>
<li>Assumes ownership of created computation node</li>
</ol>
<dl class="section warning"><dt>Warning</dt><dd><b>Infrastructure Layer</b>: Exposes fundamental mathematical operator plumbing<br  />
<b>Usage Advisory</b>: Intended for framework extensibility, not routine model building</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Supports implicit broadcasting for batch dimensions</li>
<li>Requires lhs columns == rhs rows for valid multiplication</li>
</ul>
</dd></dl>
<p>@complexity O(1) node creation + O(α(n)) graph insertion </p>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00055">55</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a31eb30e20ef27dbbb828ee006d5d1ba2" name="a31eb30e20ef27dbbb828ee006d5d1ba2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a31eb30e20ef27dbbb828ee006d5d1ba2">&#9670;&#160;</a></span>ReLU()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::ReLU </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies Rectified Linear Unit activation (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to activated output node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md65"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#a31eb30e20ef27dbbb828ee006d5d1ba2">ReLU</a>(x) = \max(0, x)</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Activation Range</b>: [0, +∞) element-wise</li>
<li><b>Gradient Behavior</b>: Zero gradient for x &lt; 0</li>
<li><b>Memory Layout</b>: Preserves input tensor shape</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Vanishing Gradient Risk</b>: Dead neurons possible in negative input regions</dd></dl>
<p>@complexity O(n) element-wise operation (n = tensor elements)</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00105">105</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a096c42733e9be0769163e96771c8fc6a" name="a096c42733e9be0769163e96771c8fc6a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a096c42733e9be0769163e96771c8fc6a">&#9670;&#160;</a></span>Reshape()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Reshape </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classnz_1_1data_1_1_dimension.html">Tensor::shape_type</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>shape</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Modifies tensor dimensions while preserving data (Low-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Source tensor node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">shape</td><td>Target dimension specification (device-to-device) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to reshaped tensor node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md63"></a>
Operation Pipeline:</h3>
<ol type="1">
<li>Validates total element count matches original tensor</li>
<li>Creates view operation without data copy</li>
<li>Maintains underlying storage reference count</li>
</ol>
<dl class="section warning"><dt>Warning</dt><dd><b>Component Tier</b>: Foundational tensor manipulation primitive<br  />
<b>Usage Context</b>: Direct access acceptable for advanced shape transformations<br  />
<b>Critical Requirement</b>: Total elements must remain constant between shapes</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Memory Layout</b>: Preserves original storage order</li>
<li><b>Device Support</b>: Works across CPU/GPU tensor implementations</li>
<li><b>Graph Impact</b>: Invalidates dependent node gradients after modification</li>
</ul>
</dd></dl>
<p>@complexity O(1) view creation + O(α(n)) graph update</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00077">77</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a8dc9c07fca0c48900ac15e4d1942deae" name="a8dc9c07fca0c48900ac15e4d1942deae"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8dc9c07fca0c48900ac15e4d1942deae">&#9670;&#160;</a></span>Sigmoid()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Sigmoid </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies logistic sigmoid activation (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to activated output node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md66"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#a8dc9c07fca0c48900ac15e4d1942deae">Sigmoid</a>(x) = 1 / (1 + exp(-x))</div>
<div class="ttc" id="aclassnz_1_1_model_html_a8dc9c07fca0c48900ac15e4d1942deae"><div class="ttname"><a href="#a8dc9c07fca0c48900ac15e4d1942deae">nz::Model::Sigmoid</a></div><div class="ttdeci">Node * Sigmoid(Node *input)</div><div class="ttdoc">Applies logistic sigmoid activation (Mid-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00115">Model.cu:115</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Activation Range</b>: (0, 1) element-wise</li>
<li><b>Usage Context</b>: Preferred for binary classification output layers</li>
<li><b>Numerical Stability</b>: Protected against extreme input values</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Gradient Saturation</b>: Avoid in deep networks due to vanishing gradients</dd></dl>
<p>@complexity O(n) element-wise exponential + division</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00115">115</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a6679925ff2f38826fc3d743eed5ba74a" name="a6679925ff2f38826fc3d743eed5ba74a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6679925ff2f38826fc3d743eed5ba74a">&#9670;&#160;</a></span>Softmax()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Softmax </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies channel-wise probability normalization (High-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Logits node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to probability distribution node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md73"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#a6679925ff2f38826fc3d743eed5ba74a">Softmax</a>(x_i) = exp(x_i) / sum(exp(x_j))</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Automatic Reshaping</b>: Input auto-converted to [N,1,C,1] format</li>
<li><b>Numerical Stability</b>: Protected via max-subtraction trick</li>
<li><b>Output Property</b>: ∑ outputs = 1 per channel</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Usage Context</b>: Final layer activation for multi-class classification</dd></dl>
<p>@complexity O(n) exponential operations + O(C) reduction per channel</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00185">185</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="a0ebe5c8d848f16af5d2a06592c3e2217" name="a0ebe5c8d848f16af5d2a06592c3e2217"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0ebe5c8d848f16af5d2a06592c3e2217">&#9670;&#160;</a></span>Sub()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Sub </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>lhs</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>rhs</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Creates subtraction operation node in computation graph (Low-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">lhs</td><td>Left operand node (device-to-device, non-owning) </td></tr>
    <tr><td class="paramname">rhs</td><td>Right operand node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to new SubNode (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md60"></a>
Graph Management:</h3>
<ol type="1">
<li>Enforces graph membership for input nodes</li>
<li>Instantiates element-wise subtraction operator</li>
<li>Registers node for automated lifecycle management</li>
</ol>
<dl class="section warning"><dt>Warning</dt><dd><b>Architectural Component</b>: Part of <a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a>'s internal graph assembly toolkit<br  />
<b>Client Guidance</b>: Prefer using composite operations via Layer APIs</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Broadcasts inputs if dimension mismatch exists</li>
<li>Graph becomes immutable after network finalization</li>
</ul>
</dd></dl>
<p>@complexity O(1) node creation + O(α(n)) graph insertion </p>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00042">42</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="aefed3cd3f03db21d52713cd5779885b4" name="aefed3cd3f03db21d52713cd5779885b4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aefed3cd3f03db21d52713cd5779885b4">&#9670;&#160;</a></span>Swish()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Swish </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies self-gated swish activation (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to activated output node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md69"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#aefed3cd3f03db21d52713cd5779885b4">Swish</a>(x) = x / (1 + exp(-x))</div>
<div class="ttc" id="aclassnz_1_1_model_html_aefed3cd3f03db21d52713cd5779885b4"><div class="ttname"><a href="#aefed3cd3f03db21d52713cd5779885b4">nz::Model::Swish</a></div><div class="ttdeci">Node * Swish(Node *input)</div><div class="ttdoc">Applies self-gated swish activation (Mid-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00145">Model.cu:145</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Self-normalizing Property</b>: Enhances deep network training stability</li>
<li><b>Differentiability</b>: Smooth everywhere compared to ReLU family</li>
<li><b>Computation Cost</b>: 2x FLOPs of ReLU due to sigmoid component</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Hardware Impact</b>: Prefer GPU acceleration for large tensors</dd></dl>
<p>@complexity O(n) element-wise operations (sigmoid + multiplication)</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00145">145</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="ac1222f9af5950074155ff7da5343d094" name="ac1222f9af5950074155ff7da5343d094"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac1222f9af5950074155ff7da5343d094">&#9670;&#160;</a></span>Tanh()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::Tanh </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Applies hyperbolic tangent activation (Mid-level API) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Feature node (device-to-device, non-owning) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to activated output node (device-resident)</dd></dl>
<h3><a class="anchor" id="autotoc_md67"></a>
Mathematical Definition:</h3>
<div class="fragment"><div class="line"><a class="code hl_function" href="#ac1222f9af5950074155ff7da5343d094">Tanh</a>(x) = (exp(x) - exp(-x)) / (exp(x) + exp(-x))</div>
<div class="ttc" id="aclassnz_1_1_model_html_ac1222f9af5950074155ff7da5343d094"><div class="ttname"><a href="#ac1222f9af5950074155ff7da5343d094">nz::Model::Tanh</a></div><div class="ttdeci">Node * Tanh(Node *input)</div><div class="ttdoc">Applies hyperbolic tangent activation (Mid-level API)</div><div class="ttdef"><b>Definition</b> <a href="_model_8cu_source.html#l00125">Model.cu:125</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Activation Range</b>: (-1, 1) element-wise</li>
<li><b>Centered Output</b>: Preferred over sigmoid for hidden layers</li>
<li><b>Gradient Profile</b>: Stronger gradients than sigmoid</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Computational Cost</b>: Higher than ReLU due to exponential operations</dd></dl>
<p>@complexity O(n) element-wise exponential operations</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00125">125</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<a id="ac56811d7f31c2c9b8acd7133d0245194" name="ac56811d7f31c2c9b8acd7133d0245194"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac56811d7f31c2c9b8acd7133d0245194">&#9670;&#160;</a></span>TargetExpand()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> * nz::Model::TargetExpand </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classnz_1_1data_1_1_dimension.html">Tensor::shape_type</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>shape</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>(Low-level) Batch expansion primitive for singleton tensors </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>Source tensor node (device-to-device, non-owning, must have batch=1) </td></tr>
    <tr><td class="paramname">shape</td><td>Target shape specification (device-to-device, NCHW format) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Pointer to batch-expanded node (device-resident)</dd></dl>
<p>Operates by replicating the singleton batch dimension N times according to:</p><ul>
<li>Input shape: [1, C, H, W] → Output shape: [N, C, H, W]</li>
<li>All batches contain identical copies of input data</li>
</ul>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Low-level Utility</b>: Prefer high-level broadcasting interfaces when possible</li>
<li><b>Shape Requirements</b>: Non-batch dimensions (C,H,W) must match target shape</li>
<li><b>Memory Amplification</b>: Output consumes N×input_memory_size</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd><b>Restricted Use</b>:<ul>
<li>Not designed for direct user invocation</li>
<li>May throw shape_mismatch_error if input violates preconditions</li>
<li>Overuse causes memory bloat in computational graphs</li>
</ul>
</dd></dl>
<p>@complexity O(N·C·H·W) memory copy operations (N = target batch size)</p>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>) </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2025/6/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00204">204</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="classnz_1_1_model_ac56811d7f31c2c9b8acd7133d0245194_cgraph.png" border="0" usemap="#aclassnz_1_1_model_ac56811d7f31c2c9b8acd7133d0245194_cgraph" alt=""/></div>
<map name="aclassnz_1_1_model_ac56811d7f31c2c9b8acd7133d0245194_cgraph" id="aclassnz_1_1_model_ac56811d7f31c2c9b8acd7133d0245194_cgraph">
<area shape="rect" title="(Low&#45;level) Batch expansion primitive for singleton tensors" alt="" coords="5,5,172,32"/>
<area shape="rect" href="classnz_1_1data_1_1_dimension.html#acc472e84b4c44f649f34b6fbb0eeacf7" title="Retrieves the value of the &#39;n&#39; dimension." alt="" coords="220,5,376,32"/>
<area shape="poly" title=" " alt="" coords="172,16,204,16,204,21,172,21"/>
</map>
</div>

</div>
</div>
<a id="a9060c98c30fb2388a9fd3ae9af67a046" name="a9060c98c30fb2388a9fd3ae9af67a046"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9060c98c30fb2388a9fd3ae9af67a046">&#9670;&#160;</a></span>update()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void nz::Model::update </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1opt_1_1_optimizer.html">opt::Optimizer</a> *</td>          <td class="paramname"><span class="paramname"><em>optimizer</em></span></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Applies parameter updates using attached optimization strategy. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">optimizer</td><td>Optimization algorithm instance (device-to-device)</td></tr>
  </table>
  </dd>
</dl>
<h3><a class="anchor" id="autotoc_md57"></a>
Update Process:</h3>
<ol type="1">
<li>Distributes optimizer to all trainable parameters</li>
<li>Executes optimization step per parameter group</li>
<li>Resets accumulated gradients</li>
</ol>
<dl class="section note"><dt>Note</dt><dd><ul>
<li><b>Ownership</b>: Does not take ownership of optimizer object</li>
<li><b>Thread Safety</b>: Requires exclusive access during execution</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>Optimizer must outlive this method call </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00020">20</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="classnz_1_1_model_a9060c98c30fb2388a9fd3ae9af67a046_cgraph.png" border="0" usemap="#aclassnz_1_1_model_a9060c98c30fb2388a9fd3ae9af67a046_cgraph" alt=""/></div>
<map name="aclassnz_1_1_model_a9060c98c30fb2388a9fd3ae9af67a046_cgraph" id="aclassnz_1_1_model_a9060c98c30fb2388a9fd3ae9af67a046_cgraph">
<area shape="rect" title="Applies parameter updates using attached optimization strategy." alt="" coords="5,47,131,73"/>
<area shape="rect" href="classnz_1_1data_1_1_tensor.html#a6fed8efad540a7621dd6640b2f2466d0" title="Resets the gradient data to zero." alt="" coords="179,47,355,73"/>
<area shape="poly" title=" " alt="" coords="131,57,163,57,163,63,131,63"/>
<area shape="rect" href="classnz_1_1cu_strm_1_1_stream_manager.html#ab4b2eb422e0e1ee44bdfdc0eb94457ce" title="Returns a reference to the singleton instance of the StreamManager." alt="" coords="403,5,588,48"/>
<area shape="poly" title=" " alt="" coords="355,44,387,40,388,45,356,50"/>
<area shape="rect" href="classnz_1_1cu_strm_1_1_stream_manager.html#a71ad766cb2869d3dd6a3931966e81706" title="Asynchronously sets a block of CUDA device memory to a specified value." alt="" coords="403,72,588,115"/>
<area shape="poly" title=" " alt="" coords="356,70,388,75,387,80,355,76"/>
<area shape="rect" href="classnz_1_1cu_strm_1_1_stream_manager.html#a1de1cf3aadea137faf90a2f9b4b7abe2" title="Acquires CUDA stream from pool using round&#45;robin scheduling." alt="" coords="636,39,822,81"/>
<area shape="poly" title=" " alt="" coords="588,77,620,73,621,78,589,83"/>
<area shape="rect" href="classnz_1_1cu_strm_1_1_stream_manager.html#adb1078a67c6e38932d7d58c2adb05ec0" title="Synchronizes CUDA stream execution until data writes complete." alt="" coords="636,105,822,148"/>
<area shape="poly" title=" " alt="" coords="589,104,621,109,620,114,588,109"/>
</map>
</div>

</div>
</div>
<h2 class="groupheader">Friends And Related Symbol Documentation</h2>
<a id="a8cc7ad3d047eee1bdb48e5fa0b16f460" name="a8cc7ad3d047eee1bdb48e5fa0b16f460"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8cc7ad3d047eee1bdb48e5fa0b16f460">&#9670;&#160;</a></span>operator&lt;&lt;()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::ostream &amp; operator&lt;&lt; </td>
          <td>(</td>
          <td class="paramtype">std::ostream &amp;</td>          <td class="paramname"><span class="paramname"><em>os</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classnz_1_1_model.html">Model</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>model</em></span>&#160;)</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Serializes neural network computation graph structure to output stream. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">os</td><td>Output stream for graph representation (host-to-device) </td></tr>
    <tr><td class="paramname">model</td><td><a class="el" href="classnz_1_1_model.html" title="Base class for constructing neural network models with automatic computation graph management.">Model</a> instance to visualize (device-to-host)</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Reference to modified output stream enabling operator chaining</dd></dl>
<p>Implements graph structure serialization by recursively traversing the computation graph. The formatted output includes:</p><ol type="1">
<li>Node hierarchy in topological order</li>
<li>Layer connectivity information</li>
<li>Tensor shape transformations</li>
</ol>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Output format may change between versions, not suitable for persistent storage</li>
<li>Not thread-safe - requires external synchronization if used concurrently</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>Modifying model during serialization may cause inconsistent output</dd></dl>
<div class="fragment"><div class="line">MyModel model;</div>
<div class="line">std::cout &lt;&lt; model;  <span class="comment">// Prints: [ComputeGraph: 15 nodes]</span></div>
<div class="line">                    <span class="comment">//         ├─ Conv2D(kernel=3x3, stride=1)</span></div>
<div class="line">                    <span class="comment">//         ├─ ReLU()</span></div>
<div class="line">                    <span class="comment">//         └─ BCELoss()</span></div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2023/10/15 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_model_8cu_source.html#l00372">372</a> of file <a class="el" href="_model_8cu_source.html">Model.cu</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/include/NeuZephyr/<a class="el" href="_model_8cuh_source.html">Model.cuh</a></li>
<li>D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/src/<a class="el" href="_model_8cu_source.html">Model.cu</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
